<?php

namespace app\api\controller;

use app\api\service\UserService;
use app\ApiController;

class UserController extends ApiController
{

    /**
     * 获取用户中心首页数据
     */
    public function index()
    {
        $userService = new UserService();
        return sparkSuccess($userService->getMyBaseInfo(\Tinywan\Jwt\JwtToken::getCurrentId()));
    }

    /**
     * 获取用户基础数据
     */
    public function info()
    {
        $userService = new UserService();
        return sparkSuccess($userService->getUserInfo(\Tinywan\Jwt\JwtToken::getCurrentId()));
    }

    /**
     * 修改用户信息
     */
    public function update()
    {
        $param = request()->post();
        $userService = new UserService();
        return sparkSuccess($userService->updateInfo($param));
    }

    /**
     * 修改绑定手机号
     */
    public function changePhone()
    {
        $param = request()->post();
        $param['user_id'] = \Tinywan\Jwt\JwtToken::getCurrentId();

        $userService = new UserService();
        return sparkSuccess($userService->changePhone($param));
    }

    /**
     * 修改密码
     */
    public function changePassword()
    {
        $param =request()->post();
        $param['user_id'] = \Tinywan\Jwt\JwtToken::getCurrentId();

        $userService = new UserService();
        return sparkSuccess($userService->changePassword($param));
    }

}
